
package cesdentalrecord.dao.view;


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

import org.apache.torque.TorqueException;

import cesdentalrecord.dao.controller.SearchController;
import cesdentalrecord.dao.controller.ViewDMFXConditionController;
import cesdentalrecord.dao.controller.ViewInitialConditionController;
import cesdentalrecord.dao.controller.ViewOralHealthServicesController;
import cesdentalrecord.dao.DmfxCond;
import cesdentalrecord.dao.InitialHealthCond;
import cesdentalrecord.dao.OralHealthService;
import cesdentalrecord.dao.Student;


public class ViewAStudentView {

	/**
	 * @param args
	 */

	int studentID;
	//ViewAStudentView vasv=new ViewAStudentView();
	
	Student s = new Student();
	
	ViewInitialConditionController vicc = new ViewInitialConditionController();
	
	ViewDMFXConditionController vdcc = new ViewDMFXConditionController();
	
	ViewOralHealthServicesController vohsc = new ViewOralHealthServicesController();
	
	
	public List<InitialHealthCond> requestViewInitialCond(int i){
		return vicc.viewInitialCondition(i);
	}
	
	public List<DmfxCond> requestViewDMFXCondition(int i){
		return vdcc.viewDMFXCondition(i);
	}
	
	public List<OralHealthService> requestViewOralHealthServices(int i){
		return vohsc.viewOralHealthServices(i);
	}
	
	public void displayViewedStudent(int i){
		ViewAStudentView vasv=new ViewAStudentView();
		vasv.setStudentID(i);
		//Basic Info
		System.out.println("Individual Treatment Record");
		System.out.println("Name: " + s.getSurname() + ", " + s.getFirstname() + " " + s.getMi());
		System.out.println("Grade and section: " + s.getGrade() + "-" + s.getSection());
		System.out.println("Gender: " + s.getGender());
		System.out.println("Date of birth: " + s.getBirthdate());
		System.out.println("Place of birth: " + s.getBirthplace());
		System.out.println("Address: " + s.getAddress());
		System.out.println("Parent/Guardian: " + s.getParent());
		System.out.println("Occupation: " + s.getOccupation());
		System.out.println("Medical History: " + s.getMedicalhist());
		
		//Initial Oral Health Condition
		List<InitialHealthCond> ihc = new ArrayList<InitialHealthCond>();
		ihc = vasv.requestViewInitialCond(i);
		vasv.displayInitialCondition(ihc);
		
		//DMFX Condition
		List<DmfxCond> dc = new ArrayList<DmfxCond>();
		dc = vasv.requestViewDMFXCondition(i);
		vasv.displayDMFXCondition(dc);
		
		//Oral Health Services Rendered
		List<OralHealthService> ohs = new ArrayList<OralHealthService>();
		ohs=vasv.requestViewOralHealthServices(i);
		try {
			vasv.displayOralHealthServices(ohs);
		} catch (TorqueException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	
	public void displayInitialCondition(List<InitialHealthCond> ihc){
		System.out.println("Oral Health Condition");
		System.out.println("Initial Oral Health Condition");
		for(InitialHealthCond i : ihc){
			System.out.println("Date of Oral Examination: " + i.getDateOfExam());
			System.out.println("Dental Caries: " + i.getDentalCarries());
			System.out.println("Gingivitis Periodental Diseases: " + i.getGingivitis());
			System.out.println("Debris: " + i.getDebris());
			System.out.println("Calculus: " + i.getCalculus());
			System.out.println("Abnormal Growth: " + i.getAbnormalGrowth());
			System.out.println("Cleft Lip/Palate: " + i.getCleftLip());
			System.out.println("Others (supernumerary/mesiodens,etc): " + i.getOther());
			System.out.println();
		}
	}
	
	public void displayDMFXCondition(List<DmfxCond> dc){
		System.out.println("DMFX Condition");
		for(DmfxCond i : dc){
			System.out.println(i);
		}
	}
	
	public void displayOralHealthServices(List<OralHealthService> ohs) throws TorqueException{
		System.out.println("Oral Health Services Rendered");
		for(OralHealthService i : ohs){
			System.out.println("Date: "+i.getDateOfService());
			System.out.println("Oral Prophy: "+i.getOralProphy());
			System.out.println("Temp. Filling: "+i.getTempFilling());
			System.out.println("Perm. Filling: "+i.getPermFilling());
			System.out.println("Sealant: "+i.getSealant());
			System.out.println("Exo.: "+i.getExo());
			System.out.println("Fluoride: "+i.getFlouride());
			System.out.println("Consultation: "+i.getConsultation());
			System.out.println("Others: "+i.getOther());
			System.out.println("Remarks: "+i.getRemark());
			System.out.println(i.getTooths());
			
		}
		
	}
	
	public void setStudentID(int studentID){
		this.studentID = studentID;
	}
	
	
	public void sendViewAStudentRequest(Student stud) throws IOException, TorqueException{
		// TODO Auto-generated method stub
		

		
/*		SearchView search  = new SearchView();
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

		String surname;
		String firstname;
		String mi;
		
		System.out.println("input Surname: ");
		surname=input.readLine();
		
		System.out.println("input Firstname: ");
		firstname=input.readLine();
		
		System.out.println("input Middle Initial: ");
		mi=input.readLine();
		
		s = search.search(surname, firstname, mi);
		
	*/	ViewAStudentView vasv=new ViewAStudentView();
		if(s != null){
			
			vasv.displayViewedStudent(stud.getStudentID());
			
		}else System.out.println("Student not found.");
		
		
	}

}
